import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "node:path";

// https://vite.dev/config/
export default defineConfig({
  // 开发服务器配置
  server: {
    port: 8089, // 设置端口为8089
    host: true, // 允许通过IP访问
    // 代理配置
    proxy: {
      "/api": {
        target: "https://map.zhibomap.com/api/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },

  // 构建配置
  build: {
    outDir: "dist",
    sourcemap: false,
  },

  // 解析配置
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
    // 文件扩展名
    extensions: [".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  },

  // 插件配置
  plugins: [vue()],
});
